# -*- coding=utf-8 -*-
import os, string, threading, time
import mutagen
import locale
import chardet

enc = locale.getpreferredencoding()


if __name__ == '__main__':
	l = '\\\\192.168.0.34\\36计\\新解36计24李代桃僵.mp3'
	filename = l.decode('utf-8')
	f = mutagen.File(filename)#.pprint().encode( 'gbk', 'replace' )
	for k, v in f.items():
		s = str(v)
		print chardet.detect( s )
		print 'V:', type(v)
		print '  -->', v
		print 'S:', type(s), s
		print '  -->', s

		u = unicode(s, 'utf-8')
		u = unicode(s, 'gbk')
		print 'U:', type(u)
		print '  -->', u.encode('gbk', 'replace')
		print '  -->', u.encode('utf-8', 'replace')

		print f.pprint().encode('gbk', 'replace')
	f = open(l, 'r')
	buf = f.read('10')
	f.close()

	pass

		# print k, type(v), s.encode('utf-8', 'replace') 
		# s = v.pprint() # .decode('utf-8')
		# s = s.encode('utf-8')
		# s = unicode( s, 'utf-8', 'replace') # .encode('gbk', 'replace')
		# print type(s), s.encode('gbk', 'replace')
		# print dir(v)

	# f = open( 'audio_record.log', 'r' )
	# l = f.readline()
	# while len(l) > 0:
	# 	filename = l[:-1].decode('utf-8')
	# 	try:
	# 		print '\n', filename
	# 		print mutagen.File(filename).pprint().encode( enc, 'replace' )
	# 	except AttributeError :
	# 		print '- Unknown file type'
	# 	except KeyboardInterrupt :
	# 		raise
	# 	except Exception, err:
	# 		print type(err), str(err)
	# 	l = f.readline()
	# f.close()


